home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2011 November
/
CHIP_2011_11.iso
/
Programy
/
Inne
/
Gry
/
Carnage_Contest
/
scripts
/
CC Original
/
weapons
/
Push.lua
< prev
next >
Wrap
Text File
|
2010-08-31
|
2KB
|
58 lines
--------------------------------------------------------------------------------
-- Weapon Push
-- Original Carnage Contest Weapon
-- Script by DC, August 2009, www.UnrealSoftware.de
--------------------------------------------------------------------------------
-- Setup Tables
if cc==nil then cc={} end
cc.push={}
-- Load & Prepare Ressources
cc.push.gfx_wpn=loadgfx("weapons/push.bmp") -- Weapon Image
setmidhandle(cc.push.gfx_wpn)
cc.push.sfx_attack=loadsfx("throw.ogg") -- Attack Sound
--------------------------------------------------------------------------------
-- Weapon: Push
--------------------------------------------------------------------------------
cc.push.id=addweapon("cc.push","Push",cc.push.gfx_wpn) -- Add Weapon
function cc.push.draw() -- Draw
-- Decrease Timer (used for arm animation)
if weapon_timer>0.0 then
weapon_timer=weapon_timer-0.5
end
-- Draw
if getplayeraction(0)==0 then
setblend(blend_alpha)
setalpha(1)
setcolor(255,255,255)
setscale(-getplayerdirection(0),1)
setrotation(0)
drawimage(cc.push.gfx_wpn,getplayerx(0)+getplayerdirection(0)*(7+weapon_timer),getplayery(0)+5)
end
end
function cc.push.attack(attack) -- Attack
if (weapon_shots<=0) then
if (attack==1) then
-- No more weapon switching!
useweapon(0)
playsound(cc.push.sfx_attack)
weapon_shots=weapon_shots+1
-- Set timer for arm animation
weapon_timer=5
-- Collision
if collision(col10x10,getplayerx(0)+getplayerdirection(0)*23,getplayery(0)+5,0,1,0)==1 then
if playercollision()~=0 and playercollision()~=playercurrent() then
playerpush(playercollision(),getplayerdirection(0)*3,-2)
end
end
-- End Turn
endturn()
end
end
end